var t = getApp();

Page({
    data: {
        type: "0",
        key: "",
        data: []
    },
    bindInput: function(t) {
        this.setData({
            key: t.detail.value
        });
    },
    clickSearch: function(a) {
        0 != this.data.key.length ? this.getData() : t.util.showToast("情输入关键字");
    },
    clickItem: function(t) {
        var a = t.currentTarget.dataset.url, e = t.currentTarget.dataset.cover, o = getCurrentPages();
        o[o.length - 2].setData({
            youkuUrl: a,
            youkuCover: e,
            src: ""
        }), wx.navigateBack({});
    },
    getData: function(a) {
        var e = this;
        t.network.post({
            url: "0" == e.data.type ? t.url.searchYouKuVideo : t.url.searchTencentVideo,
            params: {
                keyword: e.data.key
            },
            before: function() {
                wx.showLoading({
                    title: "正在搜索"
                });
            },
            success: function(a) {
                wx.hideLoading(), 1 == a.data.result ? (e.setData({
                    data: a.data.data.videos
                }), t.util.showToast(a.data.message)) : t.util.showToast(a.data.message);
            },
            fail: function() {
                wx.hideLoading(), t.util.showToast("搜索失败");
            },
            complete: function() {}
        });
    },
    onLoad: function(t) {
        this.setData({
            type: t.type
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        return {
            title: t.globalData.commonShareTitle,
            path: t.globalData.commonSharePath,
            imageUrl: t.globalData.commonShareImage,
            success: function(t) {},
            fail: function(t) {}
        };
    }
});